package per.liuchengyin.alipay.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import per.liuchengyin.alipay.mapper.OrderMapper;
import per.liuchengyin.alipay.pojo.OmsOrder;
import per.liuchengyin.alipay.pojo.PayAsyncVo;
import per.liuchengyin.alipay.pojo.PayVo;
import per.liuchengyin.alipay.pojo.TransactionStatus;
import per.liuchengyin.alipay.service.OrderService;

/**
 * @ClassName OrderServiceImpl
 * @Description 订单业务类 - 实现类
 * @Author gaofee
 * @Date 2021/3/23
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private  OrderMapper mapper;

    /**
     * 处理支付宝支付结果
     * @param vo 支付信息
     * @return
     */
    @Override
    public String handlePayResult(PayAsyncVo vo) {
        // 可以将vo里的相关支付信息保存到数据库....
        // 判断是否支付成功 - 获取状态，只有以下两种状态是支付成功了
        if (TransactionStatus.TRADE_SUCCESS.equals(vo.getTrade_status()) || TransactionStatus.TRADE_FINISHED.equals(vo.getTrade_status())) {
            // 支付成功状态 - 可以根据订单号修改数据库里订单状态为已支付....
            String outTradeNo = vo.getOut_trade_no();
        }
        return "success";
    }

/*
    @Override
    public int add(OmsOrder omsOrder) {
        return mapper.add(omsOrder);
    }
*/

    @Override
    public int update(OmsOrder omsOrder) {
        return mapper.update(omsOrder);
    }

    @Override
    public OmsOrder sele(String s) {
        return mapper.sele(s);
    }

    @Override
    public OmsOrder getorder(String orderSn) {
        return mapper.getorder(orderSn);
    }
}
